import {
  orderDelayHistory
} from '/service/service'
const {
  getCurrentStatusMap
} = require('/utils/statusMap')
Component({
  mixins: [],
  data: {
    list: [],
    columns: [{
        title: '申请时间',
        dataIndex: 'createTime',
        key: 'createTime',
        width: 190,
        fixed: true,
      },
      {
        title: '申请原因',
        dataIndex: 'delayReason',
        key: 'delayReason'
      },
      {
        title: '延期时间',
        dataIndex: 'afterDelayTime',
        key: 'afterDelayTime',
        width: 190,
      },
      {
        title: '详细信息',
        dataIndex: 'handleResult',
        key: 'handleResult',
        width: 180,
      }
    ],
  },
  props: {
    id: {
      type: 'string',
      default: ''
    }
  },
  didMount() {
    this.getList()
  },
  didUpdate() {},
  didUnmount() {},
  methods: {
    async getList() {
      try {
        const res = await orderDelayHistory({
          workOrderId: this.props.id
        })
        const list = res.map(item => {
          return {
            ...item,
            currentStatusName: getCurrentStatusMap(item.status)
          }
        })
        this.setData({
          list
        })
      } catch (e) {
        my.alert({
          content: e
        })
        console.log(e)
      }
    }
  },
});